import axios from 'axios'
import qs from 'qs'

const service = {
    request: axios.create({
        baseURL: '/',
        timeout: 10000, // request timeout
        headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
        }
    }),
};
service.request.interceptors.request.use(config => {
    const token = config.data.token;
    const hciToken = '';
    if (!config.multi) {
        config.data = qs.stringify(config.data.data)
    }
    return config
    },error => {
    console.log(error)
    Promise.reject(error)
});
service.request.interceptors.response.use(
    response => {
        if (response.data.code <= 0) {
        return Promise.reject(response.data)
        }
        return response.data
    },
    error => {
        console.log('err' + error)// for debug
        return Promise.reject(error)
    }
);

export default service;